package com.laowang.project.system.controller;

import java.util.List;

import com.laowang.common.exception.CustomException;
import com.laowang.common.utils.MobileCheck;
import com.laowang.project.system.domain.vo.AppUserSub;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.TbWpUser;
import com.laowang.project.system.service.TbWpUserService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

import javax.validation.constraints.NotBlank;

/**
 * h5用户Controller
 * 
 * @author laowang
 * @date 2023-02-10
 */
@Api(tags = "h5用户接口")
@RestController
@RequestMapping("/wPuser")
public class TbWpUserController extends BaseController {
    @Autowired
    private TbWpUserService tbWpUserService;





    @ApiOperation(value = "前端 新增h5用户",notes = "")
    @PostMapping("/addOne")
    public AjaxResult addOne(@RequestBody TbWpUser tbWpUser) {
        return toAjax(tbWpUserService.insertTbWpUser(tbWpUser));
    }



    /**
     * 查询h5用户列表
     */
    @ApiOperation(value = "查询h5用户列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:wPuser:list')")
    @GetMapping("/list")
        public TableDataInfo list(TbWpUser tbWpUser) {
        startPage();
        List<TbWpUser> list = tbWpUserService.selectTbWpUserList(tbWpUser);
        return getDataTable(list);
    }
    
    /**
     * 导出h5用户列表
     */
    @ApiOperation(value = "导出h5用户列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:wPuser:export')")
    @Log(title = "h5用户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbWpUser tbWpUser) {
        List<TbWpUser> list = tbWpUserService.selectTbWpUserList(tbWpUser);
        ExcelUtil<TbWpUser> util = new ExcelUtil<TbWpUser>(TbWpUser.class);
        return util.exportExcel(list, "wPuser");
    }

    /**
     * 获取h5用户详细信息
     */
    @ApiOperation(value = "获取h5用户详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('system:wPuser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(tbWpUserService.selectTbWpUserById(id));
    }

    /**
     * 新增h5用户
     */
    @ApiOperation(value = "新增h5用户",notes = "")
    @PreAuthorize("@ss.hasPermi('system:wPuser:add')")
    @Log(title = "h5用户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbWpUser tbWpUser) {
        return toAjax(tbWpUserService.insertTbWpUser(tbWpUser));
    }

    /**
     * 修改h5用户
     */
    @ApiOperation(value = "修改h5用户",notes = "")
    @PreAuthorize("@ss.hasPermi('system:wPuser:edit')")
    @Log(title = "h5用户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbWpUser tbWpUser) {
        return toAjax(tbWpUserService.updateTbWpUser(tbWpUser));
    }

    /**
     * 删除h5用户
     */
    @ApiOperation(value = "删除h5用户",notes = "")
    @PreAuthorize("@ss.hasPermi('system:wPuser:remove')")
    @Log(title = "h5用户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(tbWpUserService.deleteTbWpUserByIds(ids));
    }
}
